import static com.github.llyb120.performance.define.All.*;

dataset {
    name "user"
    lead {
        table "user"
        use "table"
    }

    field "id", "id", "int-conv"
    field "username", "用户名", "str-conv"
    field "true_name", "真实姓名", "str-conv"
    field "age", "年龄", "int-conv"
    field "dep", "部门", "str-conv"
    field "create_time", "创建时间", "date-conv"


}


dataset {
    name "dep"
    lead {
        table "dep"
        use "table"
    }

    field "id", "id", "int-conv"
    field "name", "部门名", "str-conv"
}


dataset {
    name "work"

    field "uid", "用户ID", "int-conv"
    field "banka", "开卡量", "int-conv"
    field "xiaoka", "销卡量", "int-conv"
    field "daikuan", "放贷量", "int-conv"
    field "licai", "理财量", "int-conv"
    field "baoxian", "保险量", "int-conv"
    field "deal_time", "办理时间", "str-conv"

    lead {
        use "table"
        table "work"
    }

    scope {
        use "table"
        sql """
            SELECT
                u.id,
                u.true_name,
                u.dep,
                sum( w.banka ) AS banka,
                sum( w.xiaoka ) AS xiaoka,
                sum( w.daikuan ) AS daikuan,
                sum( w.licai ) AS licai,
                sum( w.baoxian ) AS baoxian
            FROM
                `work` w
                LEFT JOIN `user` u ON w.uid = u.id 
            GROUP BY
                w.uid
        """

        group "dep"
    }
}


dataset {
    name "stock"
    field "code", "股票代码", "str-conv"
    field "name", "名称", "str-conv"
    field "open_price", "开盘价", "money-conv"
    field "close_price", "收盘价", "money-conv"
    field "max_price", "最高价", "money-conv"
    field "min_price", "最低价", "money-conv"
    field "trade_date", "日期", "date-conv"


    lead {
        use "table"
        table "stock"
    }

    scope {
        use "table"
        sql "select * from stock where code = '002566'"
    }
}